/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.grass.plugin;

import com.grass.plugin.dialect.DB2Dialect;
import com.grass.plugin.dialect.Dialect;
import com.grass.plugin.dialect.FirebirdDialect;
import com.grass.plugin.dialect.InformixDialect;
import com.grass.plugin.dialect.InterbaseDialect;
import com.grass.plugin.dialect.MsSQLDialect;
import com.grass.plugin.dialect.MySQLDialect;
import com.grass.plugin.dialect.OracleDialect;
import com.grass.plugin.dialect.PostgreDialect;
import com.grass.plugin.dialect.SQLiteDialect;
import com.grass.plugin.dialect.SybaseDialect;

/**
 * 方言工厂
 *
 * @author wujxiao
 * QQ 396246973
 */
public class DialectFactory {

    public static Dialect getDialectByDbtype(String dbtype) throws Exception {
        if ("MsSQL".equalsIgnoreCase(dbtype)) {
            return new MsSQLDialect();
        } else if ("Oracle".equalsIgnoreCase(dbtype)) {
            return new OracleDialect();
        } else if ("DB2".equalsIgnoreCase(dbtype)) {
            return new DB2Dialect();
        } else if ("MySQL".equalsIgnoreCase(dbtype)) {
            return new MySQLDialect();
        } else if ("Pgsql".equalsIgnoreCase(dbtype) || "postgres".equalsIgnoreCase(dbtype) || "postgresql".equalsIgnoreCase(dbtype)) {
            return new PostgreDialect();
        } else if ("SQLite".equalsIgnoreCase(dbtype)) {
            return new SQLiteDialect();
        } else if ("Firebird".equalsIgnoreCase(dbtype)) {
            return new FirebirdDialect();
        } else if ("Interbase".equalsIgnoreCase(dbtype)) {
            return new InterbaseDialect();
        }else if ("Informix".equalsIgnoreCase(dbtype)) {
            return new InformixDialect();
        } else if ("Sybase".equalsIgnoreCase(dbtype)) {
            return new SybaseDialect();
        } else {
        	throw new Exception(dbtype+ " database is not supported");
        }
    }
}
